<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
 
<head>
    <meta charset="UTF-8">
    <title>login</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
         
        html {
            height: 100%;
            width: 100%;
            overflow: hidden;
            margin: 0;
            padding: 0;
            background: url(https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F23269220-e40ae7826208808a.gif&refer=http%3A%2F%2Fupload-images.jianshu.io&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1657619652&t=7eb84824574d12b62f8e50a7d5f53e12) no-repeat 0px 0px;
            background-size: 100% 100%;
            -moz-background-size: 100% 100%;
        }
         
        body {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100%;
        }
         
        #loginDiv {
            width: 400px;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 400px;
            background-color: rgba(75, 81, 95, 0.3);
            box-shadow: 7px 7px 17px rgba(52, 56, 66, 0.5);
            border-radius: 250px;
        }
         
        
        p {
            margin-top: 30px;
            margin-left: 20px;
            color: azure;
        }
         
        input {
            margin-left: 15px;
            border-radius: 5px;
            border-style: hidden;
            height: 30px;
            width: 140px;
            background-color: rgba(216, 191, 216, 0.5);
            outline: none;
            color: #f0edf3;
            padding-left: 10px;
        }
         
        .button {
            border-color: cornsilk;
            background-color: rgba(100, 149, 237, .7);
            color: aliceblue;
            border-style: hidden;
            border-radius: 5px;
            width: 100px;
            height: 31px;
            font-size: 16px;
        }
    </style>
    <style type="text/css">
        input::-ms-input-placeholder{text-align: center;}
        input::-webkit-input-placeholder{text-align: center;}
    </style>
    <script src="https://lib.baomitu.com/vue/2.6.14/vue.min.js"></script>
    <script src="assets/js/axios.min.js"></script>

</head>

<body>
    <div id="loginDiv">
        <form action="" id="app" method="post">
            <p>账号:<input id="account" type="text" v-model="uaccount"></p>
            
            <p>密码:<input id="password" type="password" placeholder="密码不能为空" v-model="upassword"></p>
            <div style="text-align: center;margin-top: 30px;">
                <input type="button" class="button" value="登录" @click.prevent = "login">
                <input type="button" class="button" value="注册" onclick="register_click()">
            </div>
        </form>

        <script>
            //注册按钮跳转
            function register_click(){
                window.location.href="register";
            }
        </script>
        <script>
            var v = new Vue({
                el : "#app",
                data : {
                    uaccount : "",
                    upassword : ""
                },
                methods : {
                    login(){
                        let url = "adminUser/login";
                        let params = new URLSearchParams();
                        params.append("uaccount", this.uaccount);
                        params.append("upassword", this.upassword);
                        axios.post(url, params).then(res=>{
                            if(res.data.code==1){
                                if(res.data.data==0){
                                    window.location.href="admin";
                                }else{
                                    window.location.href="index";
                                }
                            }else{
                                alert(res.data.msg);
                            }
                        });
                    }
                }
            })
        </script>

    </div>
 
</body>
</html>